package com.fgr.mapper;

import com.fgr.beans.Donation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DonationMapper {
    @Insert("insert into an_donation(dn_uid,dn_tid,dn_name,dn_num,dn_date,dn_publish) values(#{dnUid},#{dnTid},#{dnName},#{dnNum},#{dnDate},#{dnPublish})")
    public Integer insertDonation(Donation donation);

    public List<Donation> selectAllDonation(Integer publish);

    public Donation selectDonationAndUserAndType(Integer dnId);

    @Select("select * from an_donation where dn_id=#{dnId}")
    public Donation selectDonationByDnId(Integer dnId);

    @Delete("delete from an_donation where dn_id=#{dnId}")
    public Integer deleteDonationByDnId(Integer dnId);

    @Update("update an_donation set dn_uid=#{dnUid},dn_tid=#{dnTid},dn_name=#{dnName},dn_num=#{dnNum},dn_date=#{dnDate} where dn_id=#{dnId}")
    public Integer updateDonation(Donation donation);

    @Update("update an_donation set dn_publish=1 where dn_id=#{dnId}")
    public Integer updateDonationPublishByDnId(Integer dnId);


    }
